<template>
  <el-config-provider :locale="locale">
    <RouterView />
  </el-config-provider>
</template>

<script setup>
import Cookies from "js-cookie";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import en from "element-plus/dist/locale/en.mjs";
import useSettingsStore from "@/store/modules/settings";
import { handleThemeStyle } from "@/utils/theme";

const locale = computed(() => (Cookies.get("language") === "en" ? en : zhCn || "zh-CN"));

onMounted(() => {
  nextTick(() => {
    // 初始化主题样式
    handleThemeStyle(useSettingsStore().theme);
  });
});
</script>
